﻿@model mBlog.ViewModels.ListView<mBlog.Data.Entities.Post>

@{
    ViewBag.Name = Model.Title;
}

<h2>Category:</h2>
<table id="postsTable" cellspacing="0">
    <tr>
        <th>
            Actions
        </th>
        <th>
            Name
        </th>
        <th>
            Category
        </th>
        <th>
            Tags
        </th>
        <th>
            Comments
        </th>
    </tr>
    <tbody>
        @foreach (var post in Model.List)
        {
            <tr>
                <td>
                    @Html.ActionLink("Delete", "DeletePost", new { postId = post.Id })
                </td>
                <td>
                    <strong>@Html.RouteLink(linkText: post.Title,
                                 routeName: "EditPost",
                                        routeValues: new { postid = post.Id })</strong>
                </td>
                <td>
                    @foreach (var category in post.Categories)
                    {
                        //var category = postCategory.Categories.ToList()[0];
                        @Html.ActionLink(category.Name, "View", new
               {
                   controller = "Category",
                   nicename = category.UrlName
               });

                    }
                </td>
                <td>
                    @foreach (var tag in post.Tags)
                    {
                        //var tag = postTag.Tags.ToList()[0];
                        @Html.ActionLink(tag.Name + ", ", "View", new { controller = "Tag", nicename = tag.UrlName });
                    }
                </td>
                <td>@post.PostedTime
                </td>
            </tr>
        }
    </tbody>
</table>
@{Html.RenderPartial("PostPager", Model.Pager);}
